// https://iai.sh.cn/problem/387
#include <bits/stdc++.h>
using namespace std;
int shu[100001];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> shu[i];
  int ans = INT_MAX;
  for (int p = 2; p <= n; p++) {
    int sumL = 0;
    for (int j = 1; j <= p - 1; j++)
      sumL += shu[j];
    int sumR = 0;
    for (int j = p; j <= n; j++)
      sumR += shu[j];
    // if(   abs( sumR-sumL  ) < ans)
    //     ans = abs( sumR-sumL);
    ans = min(ans, abs(sumR - sumL));
  }
  cout << ans;

  return 0;
}